<?php

namespace App\Http\Controllers\Admin\Member;

use App\Http\Controllers\Controller;

use App\Models\MemberRight;
use App\Models\MemberShip;
use App\Traits\Controllers\AdminTraits;
use App\Traits\Controllers\DestroyTraits;
use App\Transformers\Member\MemberRightTransFormer;
use App\Transformers\Member\MemberShipTransFormer;
use Illuminate\Http\Request;

class MemberShipController extends Controller
{
    /**
     * 会员类型 增删改查
     */
    use AdminTraits;


    public $model = MemberShip::class;

    public $transformer =MemberShipTransFormer::class;



    /**
     * 参数验证规则
     *
     * @param Request $request
     * @return array
     */
    public function rules(Request $request): array
    {
        switch ($request->method()) {
            case 'GET':
                return [];
                break;
            case 'POST':
            case 'PUT':
            case 'PATCH':
                return [
                    'type'=>'required|in_array:month,quarter,year,ever,free',
                    'title'=>'required',
                    'vip_day'=>'required|min:1',
                    'price'=>'required|min:1',
                    'new_price'=>'required|min:1',
                    'sort'=>'required',

                ];
                break;

        }
        return [];
    }

    /**
     * 验证信息
     *
     * @return array
     */
    public function ruleMessages(): array
    {
        return [
            'type.required'=>'会员类型不能为空',
            'type.in_array'=>'会员类型无效',
            'vip_day.required'=>'会员天数不能为空',
            'vip_day.min'=>'会员天数不能少于一天',
            'price.required'=>'会员价格不能为空',
            'price.min'=>'会员价格不能小于1',
            'new_price.required'=>'会员现价不能为空',
            'new_price.min'=>'会员现价不能小于1',
        ];
    }

}
